/*
 * @Author: 阿芙
 * @Date: 2021-04-10 21:33:17
 * @LastEditTime: 2021-04-17 16:04:43
 * @LastEditors: Please set LastEditors
 * @Description: 
 * @FilePath: /ManageTemplate/src/Model/SystemModel/ResultModel.js
 */

/**
 * 全局返回统一模型
 */
class ResultModel{
    constructor(ErrorCode,ErrorMessage,Result,Version){
        this.ErrorCode = ErrorCode || 0;
        this.ErrorMessage = ErrorMessage || "";
        this.Result = Result || null;
        this.v = Version || "v0";
        this.timestamp = new Date().getTime();
    }
    /**
     * 创建，返回统一模型
     * @param {*} ErrorCode 
     * @param {*} ErrorMessage 
     * @param {*} Result 
     * @returns 
     */
    static CreateModel(ErrorCode,ErrorMessage,Result,Version){
        "use strict";
        if(ErrorCode || ErrorMessage || Result || Version){
            return new ResultModel(ErrorCode,ErrorMessage,Result,Version);
        }else{
            return new ResultModel();
        }
    }

 
};

/**
 * 错误码
 * @param {*} ErrorCode 
 * @returns 
 */
ResultModel.prototype.Code = function (ErrorCode) {
    "use strict";
    this.ErrorCode = ErrorCode;
    return this;
};

/**
 * 错误信息
 * @param {*} ErrorMessage 
 * @returns 
 */
ResultModel.prototype.Message = function (ErrorMessage) {
    "use strict";
    this.ErrorMessage = ErrorMessage;
    return this;
}

/**
 * 返回内容
 * @param {*} Result 
 * @returns 
 */
ResultModel.prototype.DataResult = function (Result) {
    "use strict";
    this.Result = Result;
    return this;
};

/**
 *
 * @param Version 返回的版本
 * @returns {ResultModel}
 * @constructor
 */
ResultModel.prototype.Version = function(Version){
    "use strict";
    this.v = Version;
    return this;
}

/**
 * @description: 全局返回方法
 * @param {*}
 * @return {*}
 */
module.exports = {
    ResultModel:ResultModel,
}
